module.exports =(res,urlObj,bodyObj,sql) => {
  let query;
  if(bodyObj.id) query=`UPDATE gamemap SET list='${JSON.stringify(bodyObj.list)}', name='${bodyObj.name}',height=${bodyObj.height} ,width=${bodyObj.width} WHERE id =${bodyObj.id}`
  else  query=`INSERT INTO gamemap (list,name,width,height) VALUES ('${JSON.stringify(bodyObj.list)}','${bodyObj.name}',${bodyObj.width},${bodyObj.height})`
  sql.query(query,  (error, results, fields) =>{
    if (error) res.end(JSON.stringify({code:0,msg:"请求失败"}));
    else {
      sql.query('SELECT LAST_INSERT_ID()',(error, results, fields)=>{
        res.end(JSON.stringify({code:0,msg:"请求成功",data:{id:results[0]["LAST_INSERT_ID()"]}}));
      })
    }
  });
}
